# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Douglas Soares de Andrade <douglas@archlinux.org>

pkgbase=mtr
pkgname=('mtr' 'mtr-gtk')
pkgver=0.94
pkgrel=1
pkgdesc='Combines the functionality of traceroute and ping into one tool'
url='https://www.bitwizard.nl/mtr/'
arch=('x86_64')
license=('GPL2')
makedepends=('ncurses' 'gtk2' 'libcap')
install=mtr.install
source=(https://github.com/traviscross/mtr/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('0e58bd79562ff80f9308135562ab22aa1f1eea686aefd3aef07bac05e661e34b60fde7c66c96bf4f0919f546376fbd6106ecd8fa92328c24f6f903097496bf11')
b2sums=('e9b4619a85a515d729f0987d5882fb91e4bfa3be82476efbfdb832d0b13ed334be1c1a1bcf8ab4ca820002e79ca4a24d0b50f2739d9284b7dec0b8852a1a91e0')

prepare() {
  (cd ${pkgbase}-${pkgver}
    echo "${pkgver}" > .tarball-version
    autoreconf -fiv
  )
  cp -ra ${pkgbase}-${pkgver}{,-cli}
}

build() {
  (cd ${pkgbase}-${pkgver}-cli
    ./configure \
      --prefix=/usr \
      --without-gtk \
      --sbindir=/usr/bin
    make
  )
  (cd ${pkgbase}-${pkgver}
    ./configure \
      --prefix=/usr \
      --sbindir=/usr/bin
    make
  )
}

package_mtr() {
  pkgdesc='Combines the functionality of traceroute and ping into one tool (CLI version)'
  depends=('ncurses' 'libcap')
  optdepends=('bash-completion: bash completion support')
  cd ${pkgbase}-${pkgver}-cli
  make DESTDIR="${pkgdir}" install
}

package_mtr-gtk() {
  pkgdesc='Combines the functionality of traceroute and ping into one tool (GTK version)'
  depends=('ncurses' 'libcap' 'gtk2')
  optdepends=('bash-completion: bash completion support')
  conflicts=('mtr')
  provides=("mtr=${pkgver}")
  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install
}

# vim: ts=2 sw=2 et:
